﻿// Decompiled Using: FrontEnd Plus v2.03 and the JAD Engine
// Available From: http://www.reflections.ath.cx
// Decompiler options: packimports(3) 
// Source File Name:   HTMLFilter.java

package com.glaivelee;


public class HTMLFilter
{
	public static String source;

    public HTMLFilter()
    {
        source = "";
    }

    public static void main(String args[])
    {
        String s = "abc<>abc";
        HTMLFilter.setSource(s);
        HTMLFilter.run();
        System.out.println(HTMLFilter.source);
        System.out.println(HTMLFilter.getResult());
    }
    
    public static void run()
    {
        source = replaceHTML(source);
    }

    private static String replaceHTML(String s)
    {
        StringBuffer stringbuffer = new StringBuffer();
        for(int i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            switch(c)
            {
            case 39: // '\''
                stringbuffer.append("&#039;");
                break;

            case 34: // '"'
                stringbuffer.append("&quot;");
                break;

            case 60: // '<'
                stringbuffer.append("&lt;");
                break;

            case 62: // '>'
                stringbuffer.append("&gt;");
                break;

            case 38: // '&'
                stringbuffer.append("&amp;");
                break;

            case 32: // ' '
                stringbuffer.append("&nbsp;");
                break;

            case 10: // '\n'
                stringbuffer.append("<br>");
                break;

            default:
                stringbuffer.append(c);
                break;
            }
        }

        return stringbuffer.toString();
    }

    public static void setSource(String s)
    {
        source = s;
    }

    public static String getResult()
    {
        return source;
    }

   

    
}